package com.mercury.pattern._08_composite;

import java.util.ArrayList;
import java.util.List;

/**
 * 节点
 */
public class College extends ColleageComponent {
    /**
     * 院由系组成
     */
    List<ColleageComponent> componentList ;

    public College(String name, String desc) {
        super(name, desc);
        componentList = new ArrayList<>();
    }

    @Override
    public void add(ColleageComponent component) {
        componentList.add(component);
    }

    @Override
    public void remove(ColleageComponent component) {
        componentList.remove(component);
    }

    @Override
    public void print() {
        System.out.println("===院系：" + this.getName() +"====" + this.getDesc());
        for (ColleageComponent component : componentList) {
            //打印大学下面院系信息
            component.print();
        }
    }
}